/** * IPS Community Suite 4 * (c) 2013 Invision Power Services - http://www.invisionpower.com * * ips.submit.linkedScreenshots.js - Controller to handle linked screenshots * * Author: Mark Wade */ ;( function($, _, undefined){ "use strict"; ips.controller.register('downloads.front.submit.linkedScreenshots', { initialize: function () { this.on( 'click', '[data-action="addField"]', this.addFieldButton ); this.on( 'click', '[data-action="removeField"]', this.removeField ); this.setup(); }, /** * Setup method * * @returns {void} */ setup: function () { var initialValues = $.parseJSON( $(this.scope).attr('data-initialValue') ); if( initialValues == null ) { return; } var i; for ( i in initialValues.values ) { this.addField( i, initialValues.values[i], i == initialValues.default ); } }, /** * Add a field * * @returns {void} */ addField: function ( id, value, isDefault ) { $(this.scope).find('[data-role="fieldsArea"]').append( ips.templates.render( 'downloads.submit.linkedScreenshot', { 'name': $(this.scope).attr('data-name'), 'id': id, 'value': value, 'extra': isDefault ? 'checked' : '' }) ); }, /** * Remove a field * * @returns {void} */ removeField: function ( e ) { e.preventDefault(); $(e.currentTarget).closest('li').remove(); }, /** * Respond to add button * * @returns {void} */ addFieldButton: function () { this.addField( 'linked_' + new Date().getTime(), '', false ); } }); }(jQuery, _)); a').attr('href'); // Update page URL History.pushState( { controller: 'changelog', version: data.selectedItemID }, document.title, url ); this._loadVersion( url, data.menuElem.find('[data-ipsMenuValue="' + data.selectedItemID + '"]').attr('data-changelogTitle') ); }, /** * Event handler for History.js * When the state changes, we locate that menu item based on the version, and then pull * the version string and URL and load it * * @returns {void} */ stateChange: function () { var state = History.getState(); // Other things on the page can change the URL, so make sure this is a changelog url if( state.data.controller != 'changelog' ){ return; } var item; if( state.data.version ){ item = $('#elChangelog_menu').find('[data-ipsMenuValue="' + state.data.version + '"]'); } else { item = $('#elChangelog_menu').find('[data-ipsMenuValue]').first(); } this._loadVersion( item.find('a').attr('href'), item.attr('data-ipsMenuValue') ); }, /** * Loads version information * * @param {string} url URL of the version to load * @param {string} versionTitle Title of version being loaded * @returns {void} */ _loadVersion: function (url, versionTitle) { var self = this; // Update version this.scope.find('[data-role="versionTitle"]').text( versionTitle ); // Set height on info area and set to loading this.scope .find('[data-role="changeLogData"]') .css( { height: this.scope.find('[data-role="changeLogData"]').height() + 'px' }) .addClass('ipsLoading') .html(''); // Load the new data ips.getAjax()( url ) .done( function (response) { self.scope .find('[data-role="changeLogData"]') .html( response ) .removeClass('ipsLoading') .css({ height: 'auto' }); }) .fail( function (jqXHR, textStatus, errorThrown) { window.location = url; }); } }); }(jQuery, _));]]> /** * IPS Community Suite 4 * (c) 2013 Invision Power Services - http://www.invisionpower.com * * ips.view.download.js - Download popup controller * * Author: Rikki Tissier */ ;( function($, _, undefined){ "use strict"; ips.controller.register('downloads.front.view.download', { initialize: function () { this.on( 'click', '[data-action="dialogClose"]', this.closeDialog ); this.on( 'click', '[data-action="selectFile"]', this.selectFile ); this.on( 'click', '[data-action="download"]', this.doDownload ); }, /** * Agree to the terms and update the display to show the list * * @param {event} e Event object * @returns {void} */ selectFile: function (e) { var url = $( e.currentTarget ).attr('href'); var self = this; e.preventDefault(); // Load the download page this.scope .html('') .css({ height: '250px' }) .addClass('ipsLoading'); ips.getAjax()( url ) .done( function (response) { self.scope .html( response ) .css({ height: 'auto' }) .removeClass('ipsLoading'); }) .fail( function (jqXHR, textStatus, errorThrown) { window.location = url; }); }, /** * Event handler for the 'cancel' link * * @param {event} e Event object * @returns {void} */ closeDialog: function (e) { e.preventDefault(); this._closeDialog( $( e.currentTarget ).attr('href') ); }, /** * Closes the dialog * * @param {string} href Href to redirect to if not in a dialog * @returns {void} */ _closeDialog: function (href) { if( this.scope.closest('.ipsDialog').length ){ this.scope.closest('.ipsDialog').trigger('closeDialog'); } else { window.location = href; } }, /** * Initiate the actual download * * @param {event} e Event object * @returns {void} */ doDownload: function (e) { this.scope.closest('.ipsDialog').trigger('closeDialog'); if ( $( e.currentTarget ).attr('data-wait') ) { e.preventDefault(); ips.getAjax()( $( e.currentTarget ).attr('href') ) .done( function (response) { var secondsRemaining = response.download - response.currentTime; $( e.currentTarget ) .hide() .siblings() .find('[data-role="downloadCounter"]') .html( secondsRemaining ) .end() .end() .siblings('[data-role="downloadCounterContainer"]') .removeClass('ipsHide'); var interval = setInterval( function () { secondsRemaining--; $( e.currentTarget ).siblings().find('[data-role="downloadCounter"]').html( secondsRemaining ); if ( secondsRemaining === 0 ) { clearInterval(interval); window.location = $( e.currentTarget ).attr('href'); } }, 1000 ); }) .fail( function () { window.location = $(e.currentTarget).attr('href'); }) } } }); }(jQuery, _)); \ \ \

{{title}}

\

{{size}} · {{statusText}}

\ \ "); ips.templates.set('downloads.submit.screenshotWrapper', " \
{{{content}}}
\ "); ips.templates.set('downloads.submit.linkedScreenshot', " \
  • \ \
    \ \
    \
    \ \
    \
  • \ ");]]>
    templates common/ips.loader.js common/ui common/utils common controllers underscore jquery mustache jstz Debug.js app.js jquery.js jquery.history.js jquery.transform.js