Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add QRCode on shared folder public link
Browse files Browse the repository at this point in the history
  • Loading branch information
Afterster committed Nov 2, 2013
1 parent 66b64af commit 2022db8
Show file tree
Hide file tree
Showing 12 changed files with 682 additions and 15 deletions.
71 changes: 56 additions & 15 deletions core/src/plugins/action.share/class.ShareCenter.js
Expand Up @@ -200,6 +200,8 @@ Class.create("ShareCenter", {
// Reorganize
var repoFieldset = oForm.down('div#target_repository');
}

this.createQRCode = ajaxplorer.getPluginConfigs("ajxp_plugin[@id='action.share']").get("CREATE_QRCODE");

var ppass = new Protopass($('shared_pass'), {
barContainer : $('pass_strength_container'),
Expand Down Expand Up @@ -721,22 +723,22 @@ Class.create("ShareCenter", {
}
}
var forceOldSchool = ajaxplorer.getPluginConfigs("ajxp_plugin[@id='action.share']").get("EMAIL_INVITE_EXTERNAL");
var mailerButton;
if(dialogButtonsOrRow.hasClassName('SF_horizontal_fieldsRow')){
if(!dialogButtonsOrRow.down('#mailer_button')){
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({bottom:"<span class='icon-envelope simple_tooltip_observer' id='mailer_button' data-tooltipTitle='"+MessageHash['share_center.80']+"'> "+MessageHash['share_center.79']+"</span>"});
}
mailerButton = dialogButtonsOrRow.down('#mailer_button');
mailerButton.writeAttribute("data-tooltipTitle", MessageHash["share_center.41"]);
}else{
var oForm = dialogButtonsOrRow.parentNode;
var unShare = oForm.down("#unshare_button");
mailerButton = unShare.cloneNode(true);
mailerButton.down("img").writeAttribute("src","plugins/gui.ajax/res/themes/umbra/images/actions/22/mail_generic.png");
mailerButton.down("span").update(MessageHash["share_center.40"]);
unShare.insert({after:mailerButton});
mailerButton.writeAttribute("data-tooltipTitle", MessageHash["share_center.41"]);
var mailerButton;
if(dialogButtonsOrRow.hasClassName('SF_horizontal_fieldsRow')){
if(!dialogButtonsOrRow.down('#mailer_button')){
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({bottom:"<span class='icon-envelope simple_tooltip_observer' id='mailer_button' data-tooltipTitle='"+MessageHash['share_center.80']+"'> "+MessageHash['share_center.79']+"</span>"});
}
mailerButton = dialogButtonsOrRow.down('#mailer_button');
mailerButton.writeAttribute("data-tooltipTitle", MessageHash["share_center.41"]);
}else{
var oForm = dialogButtonsOrRow.parentNode;
var unShare = oForm.down("#unshare_button");
mailerButton = unShare.cloneNode(true);
mailerButton.down("img").writeAttribute("src","plugins/gui.ajax/res/themes/umbra/images/actions/22/mail_generic.png");
mailerButton.down("span").update(MessageHash["share_center.40"]);
unShare.insert({after:mailerButton});
mailerButton.writeAttribute("data-tooltipTitle", MessageHash["share_center.41"]);
}

if(ajaxplorer.hasPluginOfType("mailer") && !forceOldSchool){
mailerButton.observe("click", function(event){
Expand Down Expand Up @@ -786,6 +788,45 @@ Class.create("ShareCenter", {
}.bind(this));

}

if (this.createQRCode) {
if(dialogButtonsOrRow.hasClassName('SF_horizontal_fieldsRow')){
if(!dialogButtonsOrRow.down('#qrcode_button')){
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({bottom:"<span class='icon-qrcode simple_tooltip_observer' id='qrcode_button' data-tooltipTitle='"+MessageHash['share_center.94']+"'> "+MessageHash['share_center.95']+"</span>"});
}
qrcodeButton = dialogButtonsOrRow.down('#qrcode_button');
qrcodeButton.writeAttribute("data-tooltipTitle", MessageHash["share_center.95"]);
}else{
var oForm = dialogButtonsOrRow.parentNode;
var unShare = oForm.down("#unshare_button");
qrcodeButton = unShare.cloneNode(true);
qrcodeButton.down("img").writeAttribute("src","plugins/gui.ajax/res/themes/umbra/images/actions/22/qr-code.png");
qrcodeButton.down("span").update(MessageHash["share_center.94"]);
unShare.insert({after:qrcodeButton});
qrcodeButton.writeAttribute("data-tooltipTitle", MessageHash["share_center.95"]);
}
var qrcodediv = document.getElementById('share_qrcode');
qrcodediv.innerHTML = '';

qrcodeButton.observe("click", function(event){
Event.stop(event);
if(shareType == "file"){
var url = dialogButtonsOrRow.down('[name="link_url"]').getValue();
}else{
var url = this._currentRepositoryLink;
}

if (qrcodediv.innerHTML == '') {
var qrcode = new QRCode("share_qrcode", {
width: 128,
height: 128
});
qrcode.makeCode(url);
} else {
qrcodediv.innerHTML = '';
}
}.bind(this));
}
},

checkPositiveNumber : function(str){
Expand Down
6 changes: 6 additions & 0 deletions core/src/plugins/action.share/manifest.xml
Expand Up @@ -6,6 +6,7 @@
<global_param name="FILE_MAX_EXPIRATION" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Maximum share expiration limit for file, 0 = unlimited]" label="CONF_MESSAGE[Maximum file expiration limit]" type="integer" default="0" expose="true"/>
<global_param name="FILE_MAX_DOWNLOAD" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Maximum download limit for file, 0 = unlimited]" label="CONF_MESSAGE[Maximum file download limit]" type="integer" default="0" expose="true"/>
<global_param name="EMAIL_INVITE_EXTERNAL" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Use external mailer for invitations]" label="CONF_MESSAGE[Force External Mailer]" type="boolean" default="false" expose="true"/>
<global_param name="CREATE_QRCODE" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Create and display QRCode for shared link]" label="CONF_MESSAGE[Create QRCode]" type="boolean" default="false" expose="true"/>
<global_param name="AVOID_SHARED_FOLDER_SAME_LABEL" group="CONF_MESSAGE[Folder Sharing]" description="CONF_MESSAGE[Disallow users to create shared folders if a workspace already exists with the same label]" label="CONF_MESSAGE[Avoid labels duplication]" type="boolean" default="true"/>
<!--
<global_param name="SHARED_USERS_LIST_MINIMUM" group="CONF_MESSAGE[Shared users configurations]" description="CONF_MESSAGE[Minimum number of characters to start getting results by auto-completion when sharing a folder with other users]" label="CONF_MESSAGE[Autocomplete minimum chars]" type="integer" default="2" expose="true"/>
Expand Down Expand Up @@ -62,6 +63,7 @@
<client_settings>
<resources>
<i18n namespace="share_center" path="plugins/action.share/res/i18n"/>
<js file="plugins/action.share/qrcode.js" className="QRCode" autoload="true"/>
<js file="plugins/action.share/class.ShareCenter.js" className="ShareCenter" autoload="true"/>
</resources>
</client_settings>
Expand Down Expand Up @@ -118,6 +120,7 @@
<div class="dialogContentMainTitle" ajxp_message_id="share_center.29">AJXP_MESSAGE[share_center.29]</div>
<div id="generate_indicator" style="position:absolute;top:2px;right:4px;display:none;"><img src="AJXP_THEME_FOLDER/images/autocompleter-loader.gif"></div>
<textarea id="share_container" style="padding: 4px;width: 266px;height: 33px;margin:0 10px; font-size:13px;"></textarea>
<div id="share_qrcode" style="padding:4px;" />
</div>
</div>
<div id="share_folder_chooser" box_width="320">
Expand Down Expand Up @@ -207,6 +210,7 @@
<div class="dialogContentMainTitle" ajxp_message_id="share_center.29">AJXP_MESSAGE[share_center.29]</div>
<div id="generate_indicator" style="position:absolute;top:2px;right:4px;display:none;"><img src="AJXP_THEME_FOLDER/images/autocompleter-loader.gif"></div>
<textarea id="share_container" style="padding: 4px;width: 266px;height: 33px;margin:0 10px; font-size:13px;"></textarea>
<div id="share_qrcode" style="padding:4px;" />
</div>
</div>
<style type="text/css">
Expand Down Expand Up @@ -260,6 +264,7 @@
<div style="clear:left;">
<input type="text" placeholder="AJXP_MESSAGE[share_center.90]" name="link_url" id="share_container" class="SF_input SF_number" style="width:230px !important;">
<input type="text" placeholder="AJXP_MESSAGE[share_center.91]" name="link_tag" value="" class="SF_input SF_number" style="width:113px !important;">
<div id="share_qrcode" style="padding:4px;" />
</div>
<div id="handle_existing_links" class="SF_horizontal_actions">
<span data-action="remove" class="SF_horizontal_action icon-minus-sign"></span>
Expand Down Expand Up @@ -356,6 +361,7 @@
<div class="dialogContentMainTitle" ajxp_message_id="share_center.29">AJXP_MESSAGE[share_center.29]</div>
<div id="generate_indicator" style="position:absolute;top:2px;right:4px;display:none;"><img src="AJXP_THEME_FOLDER/images/autocompleter-loader.gif"></div>
<input type="text" id="share_container" style="width: 317px; margin:0 5px; font-size:13px;"/>
<div id="share_qrcode" style="padding:4px;" />
</div>
</div>
<style type="text/css">
Expand Down

0 comments on commit 2022db8

Please sign in to comment.