[Isocial-svn] SF.net SVN: isocial: [68]
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <agu...@us...> - 2008-03-12 20:37:53
|
Revision: 68 http://isocial.svn.sourceforge.net/isocial/?rev=68&view=rev Author: aguidrevitch Date: 2008-03-12 13:37:58 -0700 (Wed, 12 Mar 2008) Log Message: ----------- initial upload of javascript dialogs Modified Paths: -------------- app/views/layouts/application.tpl app/views/message/outbox.tpl app/views/message/show.tpl Added Paths: ----------- app/views/shared/dialog.tpl public/javascripts/dialog.js Modified: app/views/layouts/application.tpl =================================================================== --- app/views/layouts/application.tpl 2008-03-11 20:13:41 UTC (rev 67) +++ app/views/layouts/application.tpl 2008-03-12 20:37:58 UTC (rev 68) @@ -9,6 +9,7 @@ <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/scriptaculous.js?load=effects,controls,autocomplete" type="text/javascript"></script> <script src="/javascripts/autocomplete.js" type="text/javascript"></script> +<script src="/javascripts/dialog.js" type="text/javascript"></script> <script type="text/javascript"> function push_onload_handler (func) { if (!window._onload) window._onload = []; @@ -57,5 +58,6 @@ </div> </div> </div> +<?= $controller->renderShared('dialog') ?> </body> </html> Modified: app/views/message/outbox.tpl =================================================================== --- app/views/message/outbox.tpl 2008-03-11 20:13:41 UTC (rev 67) +++ app/views/message/outbox.tpl 2008-03-12 20:37:58 UTC (rev 68) @@ -52,7 +52,9 @@ }; function delete_threads (element) { - new Ajax.Updater('messages', + new Dialog.Box({ + onYes : function () { + new Ajax.Updater('messages', '/message/delete_outbox_thread', { method:'post', asynchronous:true, @@ -60,12 +62,22 @@ onSuccess: function () { $("delete_link").addClassName('disabled'); } - }); + } + ); + } + }); return false; } function delete_single_thread (element) { - new Ajax.Updater('messages', + new Dialog.Box({ + reference: element, + title: '_{Delete Thread}', + body: '_{Are you sure you want to delete this thread} ?', + yes: '_{Delete}', + cancel: '_{Cancel}', + onYes : function () { + new Ajax.Updater('messages', '/message/delete_outbox_thread', { method:'post', asynchronous:true, @@ -78,7 +90,10 @@ }); tocheck.invoke('click'); } - }); + } + ); + }, + }); return false; } Modified: app/views/message/show.tpl =================================================================== --- app/views/message/show.tpl 2008-03-11 20:13:41 UTC (rev 67) +++ app/views/message/show.tpl 2008-03-12 20:37:58 UTC (rev 68) @@ -24,12 +24,3 @@ </form> </div> </div> - -<div class="action_dialog" id="dlg"> - <div class="header">_{Delete Thread}</div> - <div class="body">_{Are you sure you want to delete this thread}?</div> - <div class="footer"><div class="buttons"> - <input class="submitinput" type="button" value="_{Delete}"> - <input class="cancelinput" type="button" value="_{Cancel}"> - </div></div> -</div> Added: app/views/shared/dialog.tpl =================================================================== --- app/views/shared/dialog.tpl (rev 0) +++ app/views/shared/dialog.tpl 2008-03-12 20:37:58 UTC (rev 68) @@ -0,0 +1,12 @@ +<div id="dlg" class="action_dialog" style="display: none"> + <div id="dlgheader" class="header"> </div> + <div id="dlgbody" class="body"> </div> + <div id="dlgfooter" class="footer"> + <div id="dlgbuttons" class="buttons"> + <input id="dlgyes" class="submitinput" type="button" value="_{Yes}"> + <input id="dlgno" class="submitinput" type="button" value="_{No}"> + <input id="dlgcancel" class="cancelinput" type="button" value="_{Cancel}"> + </div> + </div> +</div> + Added: public/javascripts/dialog.js =================================================================== --- public/javascripts/dialog.js (rev 0) +++ public/javascripts/dialog.js 2008-03-12 20:37:58 UTC (rev 68) @@ -0,0 +1,99 @@ +var Dialog = {}; +Dialog.Box = Class.create(); +Object.extend(Dialog.Box.prototype, { + initialize: function(options) { + + this.options = Object.extend({ + hfloat: 'right', + vfloat: 'bottom' + }, options || {}); + + if (! this.options['reference']) { + alert('Reference element is not specified'); + return; + } + + this.reference = $(this.options['reference']); + if (!this.reference) { + alert('Reference element is not specified'); + return; + } + + this.dialog = Element.extend($('dlg').cloneNode(true)); + document.body.appendChild(this.dialog); + + Object.extend(this.dialog.style, { + position: 'absolute', + zIndex: 9999, + }); + + var offset = this.reference.viewportOffset(); + var dimensions = this.reference.getDimensions(); + var vdimensions = document.viewport.getDimensions(); + + if (this.options['hfloat'] == 'right') { + this.dialog.style.right = vdimensions.width - offset.left - dimensions.width + "px"; + } else { + this.dialog.style.left = offset.left + "px"; + } + + if (this.options['vfloat'] == 'bottom') { + this.dialog.style.top = offset.top + dimensions.height + "px"; + } else { + this.dialog.style.bottom = offset.top + "px"; + } + + this.dialog.down('#dlgheader').innerHTML = this.options.title; + this.dialog.down('#dlgbody').innerHTML = this.options.body; + + this.yesButton = this.dialog.down('#dlgyes'); + this.noButton = this.dialog.down('#dlgno'); + this.cancelButton = this.dialog.down('#dlgcancel'); + + switch (this.options.yes) { + case 0, false, undefined: this.yesButton.hide(); break; + default: + this.yesButton.value = this.options.yes; + this.yesButton.observe('click', this.onYes.bind(this)); + } + + switch (this.options.no) { + case 0, false, undefined: this.noButton.hide(); break; + default: + this.noButton.value = this.options.no; + this.noButton.observe('click', this.onNo.bind(this)); + } + + switch (this.options.cancel) { + case 0, false, undefined: this.cancelButton.hide(); break; + default: + this.cancelButton.value = this.options.cancel; + this.cancelButton.observe('click', this.onCancel.bind(this)); + } + + this.dialog.show(); + + }, + + onYes: function (event) { + this.dialog.hide(); + if (this.options.onYes) { + this.options.onYes(event) + } + }, + onNo: function (event) { + this.dialog.hide(); + if (this.options.onNo) { + this.options.onNo(event) + } + }, + onCancel: function (event) { + this.dialog.hide(); + if (this.options.onCancel) { + this.options.onCancel(event) + } + } + + +}); + \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |